package com.rk.kbk.model;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.rk.kbk.common.DateJsonDeserializer;
import com.rk.kbk.common.DateJsonSerializer;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by bilibili on 2017/3/14.
 */
@Entity
public class MessageUnit implements Serializable {

    private static final long serialVersionUID = 1L;


    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @GenericGenerator(name="auto-identity",strategy="identity")
    @Column(updatable = false, columnDefinition="BIGINT(19) COMMENT ''")
    private Long id;

    @Column(columnDefinition="INT(2) COMMENT '已阅'")
    private int isRead;

    @ManyToOne
    @JoinColumn(name="user", columnDefinition="BIGINT(20) COMMENT '用户id'")
    private User user;

    @ManyToOne
    @JoinColumn(name="message", columnDefinition="BIGINT(20) COMMENT '用户id'")
    private Message message;

    /**
     * @备注:
     * @字段:gmt_datetime DATETIME(19)
     */
    @Column(updatable = false, columnDefinition="DATETIME(19) COMMENT ''")
    @JsonSerialize(using=DateJsonSerializer.class)
    @JsonDeserialize(using=DateJsonDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss" )
    private java.util.Date gmtDatetime = new java.util.Date();

    /**
     * @备注:
     * @字段:upt_datetime DATETIME(19)
     */
    @Column(columnDefinition="DATETIME(19) COMMENT ''")
    @JsonSerialize(using=DateJsonSerializer.class)
    @JsonDeserialize(using=DateJsonDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss" )
    private java.util.Date uptDatetime = new java.util.Date();
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getIsRead() {
        return isRead;
    }

    public void setIsRead(int isRead) {
        this.isRead = isRead;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public Date getGmtDatetime() {
        return gmtDatetime;
    }

    public void setGmtDatetime(Date gmtDatetime) {
        this.gmtDatetime = gmtDatetime;
    }

    public Date getUptDatetime() {
        return uptDatetime;
    }

    public void setUptDatetime(Date uptDatetime) {
        this.uptDatetime = uptDatetime;
    }
}
